/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.cs.webapp.ioms.models.impl;

import edu.cmu.cs.webapp.ioms.models.FormularRecord;
import edu.cmu.cs.webapp.ioms.models.IOMSPackage;
import edu.cmu.cs.webapp.ioms.models.Ingredient;

import edu.cmu.cs.webapp.ioms.models.Product;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Formular Record</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.FormularRecordImpl#getForm_id <em>Form id</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.FormularRecordImpl#getIng_std_quantity <em>Ing std quantity</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.FormularRecordImpl#getIngredient <em>Ingredient</em>}</li>
 *   <li>{@link edu.cmu.cs.webapp.ioms.models.impl.FormularRecordImpl#getProduct <em>Product</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FormularRecordImpl extends EObjectImpl implements FormularRecord {
	/**
	 * The default value of the '{@link #getForm_id() <em>Form id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForm_id()
	 * @generated
	 * @ordered
	 */
	protected static final int FORM_ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getForm_id() <em>Form id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForm_id()
	 * @generated
	 * @ordered
	 */
	protected int form_id = FORM_ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getIng_std_quantity() <em>Ing std quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIng_std_quantity()
	 * @generated
	 * @ordered
	 */
	protected static final double ING_STD_QUANTITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getIng_std_quantity() <em>Ing std quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIng_std_quantity()
	 * @generated
	 * @ordered
	 */
	protected double ing_std_quantity = ING_STD_QUANTITY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getIngredient() <em>Ingredient</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIngredient()
	 * @generated
	 * @ordered
	 */
	protected Ingredient ingredient;

	/**
	 * The cached value of the '{@link #getProduct() <em>Product</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProduct()
	 * @generated
	 * @ordered
	 */
	protected Product product;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FormularRecordImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return IOMSPackage.Literals.FORMULAR_RECORD;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getForm_id() {
		return form_id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setForm_id(int newForm_id) {
		int oldForm_id = form_id;
		form_id = newForm_id;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.FORMULAR_RECORD__FORM_ID, oldForm_id, form_id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getIng_std_quantity() {
		return ing_std_quantity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIng_std_quantity(double newIng_std_quantity) {
		double oldIng_std_quantity = ing_std_quantity;
		ing_std_quantity = newIng_std_quantity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.FORMULAR_RECORD__ING_STD_QUANTITY, oldIng_std_quantity, ing_std_quantity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Ingredient getIngredient() {
		if (ingredient != null && ingredient.eIsProxy()) {
			InternalEObject oldIngredient = (InternalEObject)ingredient;
			ingredient = (Ingredient)eResolveProxy(oldIngredient);
			if (ingredient != oldIngredient) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, IOMSPackage.FORMULAR_RECORD__INGREDIENT, oldIngredient, ingredient));
			}
		}
		return ingredient;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Ingredient basicGetIngredient() {
		return ingredient;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIngredient(Ingredient newIngredient) {
		Ingredient oldIngredient = ingredient;
		ingredient = newIngredient;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.FORMULAR_RECORD__INGREDIENT, oldIngredient, ingredient));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Product getProduct() {
		if (product != null && product.eIsProxy()) {
			InternalEObject oldProduct = (InternalEObject)product;
			product = (Product)eResolveProxy(oldProduct);
			if (product != oldProduct) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, IOMSPackage.FORMULAR_RECORD__PRODUCT, oldProduct, product));
			}
		}
		return product;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Product basicGetProduct() {
		return product;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setProduct(Product newProduct) {
		Product oldProduct = product;
		product = newProduct;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IOMSPackage.FORMULAR_RECORD__PRODUCT, oldProduct, product));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case IOMSPackage.FORMULAR_RECORD__FORM_ID:
				return getForm_id();
			case IOMSPackage.FORMULAR_RECORD__ING_STD_QUANTITY:
				return getIng_std_quantity();
			case IOMSPackage.FORMULAR_RECORD__INGREDIENT:
				if (resolve) return getIngredient();
				return basicGetIngredient();
			case IOMSPackage.FORMULAR_RECORD__PRODUCT:
				if (resolve) return getProduct();
				return basicGetProduct();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case IOMSPackage.FORMULAR_RECORD__FORM_ID:
				setForm_id((Integer)newValue);
				return;
			case IOMSPackage.FORMULAR_RECORD__ING_STD_QUANTITY:
				setIng_std_quantity((Double)newValue);
				return;
			case IOMSPackage.FORMULAR_RECORD__INGREDIENT:
				setIngredient((Ingredient)newValue);
				return;
			case IOMSPackage.FORMULAR_RECORD__PRODUCT:
				setProduct((Product)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case IOMSPackage.FORMULAR_RECORD__FORM_ID:
				setForm_id(FORM_ID_EDEFAULT);
				return;
			case IOMSPackage.FORMULAR_RECORD__ING_STD_QUANTITY:
				setIng_std_quantity(ING_STD_QUANTITY_EDEFAULT);
				return;
			case IOMSPackage.FORMULAR_RECORD__INGREDIENT:
				setIngredient((Ingredient)null);
				return;
			case IOMSPackage.FORMULAR_RECORD__PRODUCT:
				setProduct((Product)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case IOMSPackage.FORMULAR_RECORD__FORM_ID:
				return form_id != FORM_ID_EDEFAULT;
			case IOMSPackage.FORMULAR_RECORD__ING_STD_QUANTITY:
				return ing_std_quantity != ING_STD_QUANTITY_EDEFAULT;
			case IOMSPackage.FORMULAR_RECORD__INGREDIENT:
				return ingredient != null;
			case IOMSPackage.FORMULAR_RECORD__PRODUCT:
				return product != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (form_id: ");
		result.append(form_id);
		result.append(", ing_std_quantity: ");
		result.append(ing_std_quantity);
		result.append(')');
		return result.toString();
	}

} //FormularRecordImpl
